package accounting_system;

import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextArea;
import javax.swing.JTextField;

public class EnterFrame extends JFrame{
    
    public EnterFrame(){
        super("Вход в систему");
        
        JPanel panel = new JPanel();
        JTextArea infoField = new JTextArea();
        JLabel loginLabel = new JLabel("Логин");
        JTextField loginField = new JTextField();
        JLabel passwordLabel = new JLabel("Пароль");
        JTextField passwordField = new JPasswordField();
        JButton enterButton = new JButton("Вход");
        JButton cancelButton = new JButton("Отмена");
        
        //"Нет подключения к серверу или нет доступа к базе данных. Для создания новой базы данных используйте логин - \"admin\" и пароль \"password\""
        
        infoField.setText("Введите свои индетификационные\nданные, или обратитесь к администратору сети.");
        infoField.setEditable(false);
        infoField.setLineWrap(true);
        //infoField.setColumns(20);
        //infoField.setRows(5);
        
        
        panel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5), BorderFactory.createEtchedBorder(1)));
        
        panel.setLayout(new GridBagLayout());
        GridBagConstraints gbc = new GridBagConstraints();
        
        gbc.insets.set(15, 5, 0, 5);
        gbc.fill = GridBagConstraints.BOTH;
        gbc.gridwidth = GridBagConstraints.LINE_END;
        panel.add(infoField, gbc);
        
        gbc.insets.top = 5;
        gbc.fill = GridBagConstraints.NONE;
        gbc.anchor = GridBagConstraints.WEST;
        gbc.gridwidth = 1;
        gbc.gridx = GridBagConstraints.REMAINDER;
        gbc.gridy = 1; //GridBagConstraints.REMAINDER;
        panel.add(loginLabel, gbc);
        
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.gridx = GridBagConstraints.RELATIVE;
        gbc.gridwidth = GridBagConstraints.LINE_END;
        panel.add(loginField, gbc);
        
        gbc.gridx = GridBagConstraints.REMAINDER;
        gbc.gridy = 2;//GridBagConstraints.RELATIVE;
        gbc.gridwidth = 1;
        panel.add(passwordLabel, gbc);
        
        //gbc.insets.bottom = 15;
        gbc.gridx = GridBagConstraints.RELATIVE;
        gbc.gridwidth = GridBagConstraints.LINE_END;
        panel.add(passwordField, gbc);
        
        gbc.fill = GridBagConstraints.NONE;
        gbc.gridx = GridBagConstraints.REMAINDER;
        gbc.gridy = 3;//GridBagConstraints.RELATIVE;
        gbc.gridwidth = 1;
        panel.add(new JPanel(), gbc);
        
        gbc.insets.bottom = 15;
        gbc.anchor = GridBagConstraints.LINE_END;
        gbc.gridx = GridBagConstraints.RELATIVE;
        panel.add(enterButton, gbc);
        
        gbc.gridx = GridBagConstraints.RELATIVE;
        panel.add(cancelButton, gbc);
        
        getContentPane().add(panel);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setLocationRelativeTo(null);
        setResizable(false);
        pack();
        setVisible(true);
    }
}
